import request from "@/utils/request.js";
import api from "@/api/index.js";

/**
 * 登录成功请求获取用户信息
 * @returns {*}
 */
export const reqGetUserInfo = () => {
    return request({
        url: api.getUserInfoURL,
        method: "GET",
    })
}

/**
 * 请求获取全部用户
 * @returns {*}
 */
export const reqGetAllAccount = () => {
    return request({
        url: api.reqGetAllAccountURL,
        method: "GET"
    })
}

/**
 * 条件查询用户
 * @returns {*}
 */
export const reqAccountListByCondition = (like) => {
    return request({
        url: api.reqAccountListByConditionURL+`?like=${like}`,
        method: "GET"
    })
}


/**
 * 添加用户
 * @param accountModel
 * @returns {*}
 */
export const reqAddAccount = (accountModel) => {
    return request({
        url: api.reqAddAccountURL,
        method: "POST",
        data: accountModel
    })
}

/**
 * 添加用户
 * @param data
 * @returns {*}
 */
export const reqUpdateAccount = (data) => {
    return request({
        url: api.reqUpdateAccountURL,
        method: "PUT",
        data
    })
}

/**
 * 通过用户ids批量删除
 * @param ids
 * @returns {*}
 */
export const reqRemoveBatchAccountByIds = (ids) => {
    return request({
        url: api.reqRemoveBatchAccountByIdsURL,
        method: 'DELETE',
        data: ids
    })
}


/**
 * 通过用户id查询角色ids
 * @param accountId
 * @returns {*}
 */
export const reqRoleIdsByAccountId = (accountId) => {
    return request({
        url: api.reqRoleIdsByAccountIdURL + `/${accountId}`,
        method: 'GET'
    })
}

/**
 * 为用户分配角色
 * @param roleIds
 * @param accountId
 * @returns {*}
 */
export const reqGiveRoles4Account = (roleIds, accountId) => {
    return request({
        url: api.reqGiveRoles4AccountURL + `/${accountId}`,
        method: 'POST',
        data: roleIds
    })
}

/**
 * 请求重置密码
 * @param account
 * @returns {*}
 */
export const reqResetPasswordById = (account) => {
    return request({
        url: api.reqResetPasswordByIdURL,
        method: 'PUT',
        data: account
    })
}

/**
 * 忘记密码
 * @param data
 * @returns {*}
 */
export const reqForgetPassword=(data)=>{
    return request({
        url:api.reqForgetPasswordURL,
        method:'POST',
        data
    })
}

/**
 * 修改用户自己的密码
 * @param data
 * @returns {*}
 */
export const reqUpdateSelfPassword=(data)=>{
    return request({
        url:api.reqUpdateSelfPasswordURL,
        method:'POST',
        data
    })
}

/**
 * 修改绑定的邮箱
 * @param data
 * @returns {*}
 */
export const reqUpdateBindEmail=(data)=>{
    return request({
        url:api.reqUpdateBindEmailURL,
        method:'POST',
        data
    })
}
